67-add-binary.py
problem: ---
problem:

Given two binary strings, return their sum (also a binary string).
The input strings are both non-empty and contains only characters 1 or 0.

Example 1:
Input: a = "11", b = "1"
Output: "100"

Example 2:
Input: a = "1010", b = "1011"
Output: "10101"
---

-----------------------------------------------------------------------
bug_fixes: ---
bug_fixes:
Add a colon to the end of line 2.
Replace `1` with `'1'` on line 18.
Replace `res[::-1].join('')` with `''.join(res[::-1])` on line 21.
---

-----------------------------------------------------------------------
bug_desc: ---
bug_desc:
On line 2, a colon is missing from the method definition, causing it to not terminate. This is a syntactical bug that can be fixed by adding a colon at the end.
On line 18, carry is a string variable, but is being compared to an int - the condition will always be false. To fix the bug, compare carry with '1' (as a string).
On line 21, the syntax for the join() method is wrong, as join() is a string method. The arguments needs to be reversed to fix the bug, like so: ''.join(res[::-1]).
---

-----------------------------------------------------------------------
line_no: ---
line_no:
2
---

-----------------------------------------------------------------------
buggy_code: ---
buggy_code:
1. class Solution:
2.     def addBinary(self, a: str, b: str) -> str
3.       res = []
4.       i = len(a) - 1
5.       j = len(b) - 1
6.       carry = '0'
7.       while i >= 0 or j >=0:
8.         ach = a[i] if i >= 0 else '0'
9.         bch = b[j] if j >= 0 else '0'
10.         if ach == bch:
11.           res.append(carry)
12.           carry = ach
13.         else:
14.           res.append('1' if carry == '0' else '0')
15.         i -= 1
16.         j -= 1
17.       
18.       if carry == 1:
19.         res.append(carry)
20.       
21.       return res[::-1].join('')
---

-----------------------------------------------------------------------
correct_code: ---
correct_code:
1. class Solution:
2.     def addBinary(self, a: str, b: str) -> str:
3.       res = []
4.       i = len(a) - 1
5.       j = len(b) - 1
6.       carry = '0'
7.       while i >= 0 or j >=0:
8.         ach = a[i] if i >= 0 else '0'
9.         bch = b[j] if j >= 0 else '0'
10.         if ach == bch:
11.           res.append(carry)
12.           carry = ach
13.         else:
14.           res.append('1' if carry == '0' else '0')
15.         i -= 1
16.         j -= 1
17.       
18.       if carry == '1':
19.         res.append(carry)
20.       
21.       return ''.join(res[::-1])
---

-----------------------------------------------------------------------
